var xmlhttp;
function GetXmlHttpObject()
{
    if (window.XMLHttpRequest)
    {
        return new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
    return null;
}
function HienThiDanhMuc(Id)
{
    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null)
    {
        alert ("Your browser does not support XML HTTP Request");
        return;
    }
    xmlhttp.onreadystatechange = showResult;
    var url = "TacPham.php?Id="+Id;
    url += "&t=" + Math.random();
    xmlhttp.open("GET", url, true);
    xmlhttp.send(null);
}
function PhanTrang(Id,p)
{
    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null)
    {
        alert ("Your browser does not support XML HTTP Request");
        return;
    }
    xmlhttp.onreadystatechange = showResult;
    var url = "TacPham.php?Id="+Id+"& page=" + p;
    url += "&t=" + Math.random();
    xmlhttp.open("GET", url, true);
    xmlhttp.send(null);
}
function getBrowserHeight() { 
	var intH = 0; 
	var intW = 0; 
	if(typeof window.innerWidth  == 'number' ) { 
	intH = window.innerHeight; 
	intW = window.innerWidth; 
	}  
	else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { 
	intH = document.documentElement.clientHeight; 
	intW = document.documentElement.clientWidth; 
	} 
	else if(document.body && (document.body.clientWidth || document.body.clientHeight)) { 
		intH = document.body.clientHeight; 
		intW = document.body.clientWidth; 
		} 
	return { width: parseInt(intW), height: parseInt(intH) }; 
	}   
	function setLayerPosition() { 
	var shadow = document.getElementById("shadow"); 
	var question = document.getElementById("question"); 
	var bws = getBrowserHeight(); 
	shadow.style.width = bws.width + "px"; 
	shadow.style.height = bws.height + "px"; 
	question.style.left = parseInt((bws.width - 400) / 2); 
	question.style.top = parseInt((bws.height - 400) / 2); 
	shadow = null; 
	question = null; 
	} 
function showLayer() { 
	setLayerPosition(); 
	var shadow = document.getElementById("shadow"); 
	var question = document.getElementById("question"); 
	shadow.style.display = "block";  
	question.style.display = "block"; 
	shadow = null; 
	question = null;              
} 
function hideLayer() { 
	var shadow = document.getElementById("shadow"); 
	var question = document.getElementById("question"); 
	shadow.style.display = "none";  
	question.style.display = "none"; 
	shadow = null; 
	question = null;  
}     
function Contact()
{
    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null)
    {
        alert ("Your browser does not support XML HTTP Request");
        return;
    }
    xmlhttp.onreadystatechange = showResult;
    var url = "LienHe.php";
    xmlhttp.open("GET", url, true);
    xmlhttp.send(null);
}
function btnGuiMail()
{
    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null)
    {
        alert ("Your browser does not support XML HTTP Request");
        return;
    }
    xmlhttp.onreadystatechange = showResult;
    var sender = document.getElementById("sender").value;
    var subject = document.getElementById("subject").value;
    var message = document.getElementById("message").value;
    var url = "XuLyLienHe.php?Sender="+sender+"&Subject="+subject+"&Message="+message;
    xmlhttp.open("GET", url, true);
    xmlhttp.send(null);
}  
function showResult()
{
el=document.getElementById("Result"); 
el.innerHTML="<img src='images/loading.gif' class='loading'/>";
    if (xmlhttp.readyState==4 && xmlhttp.status == 200)
    {
	    el.innerHTML=xmlhttp.responseText;
		eval("da load xong");

    }
}